package cn.gson.fengboot.controller;


import cn.gson.fengboot.model.pojos.*;
import cn.gson.fengboot.model.service.QhandledService;
import cn.gson.fengboot.model.service.QproductService;
import cn.gson.fengboot.model.service.QpurchaseService;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/per")
public class Chanpcaigou {
    @Autowired
    QpurchaseService qpurchaseService;

    @Autowired
    QhandledService qhandledService;


    //采购查询
    @RequestMapping("/caigou-list")
    @ResponseBody
    public Map<String ,Object> select1(Integer pageNum, Integer PageSize){
        Page<Object> obj= PageHelper.startPage(pageNum,PageSize);
        qpurchaseService.caigouList();
        Map<String,Object> map=new HashMap<>();
        map.put("total",obj.getTotal());
        map.put("rows",obj.getResult());
        return map;
    }

    //供应商查询
    @RequestMapping("/gys-list")
    @ResponseBody
    public List<QhandledEntity> QhandledList(){
        return qhandledService.QhandledList();
    }


    @RequestMapping("/xinz-caigou")
    @ResponseBody
    public  void addcaigou(@RequestBody QpurchaseEntity qcaigouxz){
////        Qcaigouxz qcaigouxz1 = JSONObject.parseObject(qcaigouxz,Qcaigouxz.class);
        qhandledService.addcpcg(qcaigouxz);
    }

}
